﻿using DFGK_WMS.Model.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DFGK_WMS.Model.DTO
{
    public class ReceivingDetailsDTO : IEqualityComparer<TReceivingBillDetail>
    {

        public bool Equals(TReceivingBillDetail x, TReceivingBillDetail y)
        {
            return x.Id == y.Id && x.MaterialCode == y.MaterialCode && x.BatchNo == y.BatchNo && x.OwnerName == y.OwnerName && x.Qty == y.Qty;
        }

        public int GetHashCode([DisallowNull] TReceivingBillDetail obj)
        {
            unchecked
            {
                int hash = 17;
                hash = hash * 23 + (obj.MaterialCode != null ? obj.MaterialCode.GetHashCode() : 0);
                hash = hash * 23 + (obj.BatchNo != null ? obj.BatchNo.GetHashCode() : 0);
                hash = hash * 23 + (obj.OwnerName != null ? obj.OwnerName.GetHashCode() : 0);
                hash = hash * 23 + obj.Qty.GetHashCode();
                return hash;
            }
        }
    }

    // 自定义相等比较器，实现对多个属性的比较
    public class MyClassComparer : IEqualityComparer<TReceivingBillDetail>
    {
        public bool Equals(TReceivingBillDetail x, TReceivingBillDetail y)
        {
            return x.Id == y.Id && x.MaterialCode == y.MaterialCode;
        }

        public int GetHashCode(TReceivingBillDetail obj)
        {
            return obj.Id.GetHashCode() ^ obj.MaterialCode.GetHashCode();
        }
    }
}
